
package org.aha.ahaxproject.servlet.xmlreqservlet;

import org.japril.servlet.WebAppUser;
import org.japril.servlet.xmlservlet.EnvironmentInitializer;
import org.japril.servlet.xmlservlet.XmlRequestServlet;

/**
 * <p>
 * </p>
 * @author Arne Halvorsen (AH)
 */
@SuppressWarnings("serial")
public final class MyXmlRequestServlet extends XmlRequestServlet
{
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  public MyXmlRequestServlet(){}

  @Override
  protected EnvironmentInitializer newEnvironmentInitializer(WebAppUser wau)
  {
    return new MyEnvironmentInitializer();
  }
  
  /*
  // Specified in XmlRequestServlet.
  protected WebAppUser authenticate(HttpServletRequest req,
    HttpServletResponse resp) throws IOException 
  {
    String thisURL=req.getRequestURI();
    
    UserService us=UserServiceFactory.getUserService();
    
    Principal principal=req.getUserPrincipal();
    if (principal==null)
    {
      resp.setContentType("text/html");
      PrintWriter pw=resp.getWriter();
      
      StringBuilder sb=new StringBuilder();
      
      pw.println("<html><body>");
      pw.println("<h1>Welcome to Aha's eXperimental Project</h1>");
     
      String lurl=us.createLoginURL(thisURL);
      
      sb.append("<h2><a href='").append(lurl)
        .append("'>Login Using Your Google Account</a></h2>");
      
      pw.println(sb);
      
      return null;
    }
    else
    {
      return new WebAppUser().setName(principal.getName())
                             .setLogoutUrl(us.createLogoutURL(thisURL));
    }
  }
  */
  
}
